<template></template>
<script setup>
import { useRouter } from 'vue-router'
import { useRouterStore } from '@/pinia/modules/router'
import { onMounted } from 'vue'

const routerStore = useRouterStore()
const router = useRouter()
const allRouters = routerStore.asyncRouters.allRoutes
const getDefaultMenu = async routes => {
  if (routes?.length > 0) {
    if (routes[0].children?.length === 0) {
      router.push(routes[0].path)
    } else {
      // 递归找到默认菜单
      getDefaultMenu(routes[0].children)
    }
  }
}
onMounted(() => {
  getDefaultMenu(allRouters[0].children)
})
</script>
<style lang="scss" scoped></style>
